#include <string.h>

struct lib_pair
{
    char *str;
    int num;
    int area;
};

struct lib_pair lib[] = {
    // sign hash    --- 0(area)
    {"SHA1", 1,         0},

    // rsa padding  --- 1
    {"no padding", 0,   1},
    {"pkcs1", 1,        1},
    {"oaep", 2,         1},
};

char *int_2_str(int num, int area) {
    for (int i=0;i<sizeof(lib)/sizeof(struct lib_pair);i++) {
        if (lib[i].area != area) continue;
        if (lib[i].num == num) return lib[i].str;
    }
    return NULL;
}

int str_2_int(char *str, int area) {
    for (int i=0;i<sizeof(lib)/sizeof(struct lib_pair);i++) {
        if (lib[i].area != area) continue;
        if (strcmp(lib[i].str, str)) return lib[i].num;
    }
    return -1;
}